class PostsController < ApplicationController
  # POST /api/discussions/1/posts
  def create
    @discussion = Discussion.find(params[:id])
    @post = @discussion.posts.create(:body => params[:body], :timestamp => Time.now)
	success = @post.errors.count == 0
	render_for_api :public, :json => @post, :status => :created if success
	render :json => @post.errors, :status => :unprocessable_entity if !success
  end

  # GET /api/discussions/1/posts
  def post_list
    @discussion = Discussion.find(params[:id])
    render_for_api :public, :json => @discussion.posts, :root => :posts
  end
end
